package pri.syl.xiaowu.websocket.init;

import pri.syl.xiaowu.websocket.annotation.WebsocketRoute;
import pri.syl.xiaowu.websocket.init.core.factory.execution.WebsocketRouteInitFactoryExecution;
import lombok.Data;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.NonNull;

import javax.annotation.PostConstruct;

/**
 * ClassName: WebsocketRouteInit
 * Description:
 * date: 2020/8/17 22:43
 * 获取容器中被注解声明的配置类
 *
 * @author ThierrySquirrel
 * @since JDK 1.8
 */
@Data
public class WebsocketRouteInit implements ApplicationContextAware {
    private ApplicationContext applicationContext;


    @PostConstruct
    public void init() {
        WebsocketRouteInitFactoryExecution.execution(applicationContext.getBeansWithAnnotation(WebsocketRoute.class));
    }

    @Override
    public void setApplicationContext(@NonNull ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }
}
